﻿@inject IUserService _userService

@inject IHttpService _httpService
@inject IDataCacheService _dataCacheService
@inject IStructuredDataService _structuredDataService
@inject NavigationManager NavigationManager
@inject IMauiService _mauiService
<CnGalWebSite.Shared.MasaComponent.Shared.Cards.TitleTip/>



<MTabsItems Value="_dataCacheService.HomeTabIndex"Class="pb-12">
    <MTabItem Value="0">
        <div id="home-page"> 
            
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Chronological.CarouselsCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Chronological.ButtonGroupCard/>
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Chronological.BirthdayCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Chronological.RecommendsCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Chronological.PublishedGamesCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Chronological.UpcomingGamesCard />

            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Thematic.FreeGamesCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Thematic.DiscountGamesCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Chronological.LatestArticlesCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Chronological.LatestVideoesCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Chronological.CommunityCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Chronological.FriendLinksCard />
        </div>
    </MTabItem>
    <MTabItem Value="1">
        <div id="home-page">
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Thematic.EvaluationsCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Recommends.MainCard />

        </div>

    </MTabItem>
    <MTabItem Value="2">
        <div id="home-page">
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Chronological.NewsCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Chronological.WeeklyNewsCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Thematic.HotTagsCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Thematic.LatastCommentsCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Chronological.AnnouncementsCard />
            <CnGalWebSite.Shared.MasaComponent.PC.Home.Cards.Chronological.RecentlyEditedGamesCard />

        </div>

    </MTabItem>
    <MTabItem Value="3">
        <AuthorizeView>
            <Authorized>
                <CnGalWebSite.Shared.Pages.Webs.Space.Index Id="@_dataCacheService.UserInfor.Id"></CnGalWebSite.Shared.Pages.Webs.Space.Index>
            </Authorized>
            <NotAuthorized>
                <div class="w-100" style="height: calc(100vh); display: flex; justify-content: center; align-items: center; ">
                    <CnGalWebSite.Components.Buttons.MasaButton Rounded Text="登入后进入个人空间" Icon="mdi-login" OnClick="_userService.Login" />
                </div>
            </NotAuthorized>
        </AuthorizeView>
    </MTabItem>
</MTabsItems>

<MFooter Fixed Padless>
    <MBottomNavigation Value="_dataCacheService.HomeTabIndex"  ValueChanged="ValueChanged" Shift Grow>
        <MButton ActiveClass="nav-bottom-tab-active" Value="0">
            <span>主页</span>
            <MIcon>@IconType.Home.ToIconString()</MIcon>
        </MButton>
        <MButton ActiveClass="nav-bottom-tab-active" Value="1">
            <span>探索</span>
            <MIcon>@IconType.Explore.ToIconString()</MIcon>
        </MButton>
        <MButton ActiveClass="nav-bottom-tab-active" Value="2">
            <span>广场</span>
            <MIcon>@IconType.Shape.ToIconString()</MIcon>
        </MButton>
        <MButton ActiveClass="nav-bottom-tab-active" Value="3">
            <span>空间</span>
            <MIcon>@IconType.User.ToIconString()</MIcon>
        </MButton>
    </MBottomNavigation>
</MFooter>

@code {

    [CascadingParameter]
    public ErrorHandler ErrorHandler { get; set; }


    protected override void OnAfterRender(bool firstRender)

    {
        if (firstRender)
        {
            //通知MAUI
            _mauiService.OnLoaded();
        }
    }

    public void ValueChanged(StringNumber value)
    {
        _dataCacheService.HomeTabIndex = value.ToInt32();
    }
}
